<?php
// This file is part of Preg question type - https://code.google.com/p/oasychev-moodle-plugins/
//
// Preg question type is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * This file is part of tReger
 * @package    qtype_preg
 * @copyright  2012 Oleg Sychev, Volgograd State Technical University
 * @author     Penskoy Nikita <nik95penik@yandex.ru>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

defined('MOODLE_INTERNAL') || die();

/**
 * Заменяет в строке html новые значения шаблонов на первоначальные
 * \param[in,out] html_str  – строка для записи html файла
 * \param[in] templates - шаблоны
 */
function replace_temp_to_previous($html, $templates) {
    $color = '';
    for ($i = count($templates); $i >= 0; $i--) {
        $pos = 0;
        do {
            $pos = html->find($color . $templates[i]->replacingname, $pos);
            if ($pos > 0) {
                // html.erase(pos + 22, templates[i].replacingname.length());
                // html.insert(pos + 22, templates[i].name);
            }
        } while (pos > 0);
    }
    return $html;
}


